package com.jianganming.interpreter;

import java.util.Arrays;
import java.util.List;

public class OperatorUtil {
    private static List<String> one= Arrays.asList("*","/");
    private static List<String> two= Arrays.asList("+","-");


    public static Boolean isOneOperator(String operator){
        return one.contains(operator);
    }

    public static Boolean isTwoOperator(String operator){
        return two.contains(operator);
    }

    public static Interpreter getInterpreter(IArithmeticInterpreter left, IArithmeticInterpreter right, String symbol){
        if("+".equals(symbol)){
            return new AddInterpreter(left,right);
        }
        if("-".equals(symbol)){
            return new SubInterpreter(left,right);
        }
        if("*".equals(symbol)){
            return new MultiInterpreter(left,right);
        }
        if("/".equals(symbol)){
            return new DivInterpreter(left,right);
        }
        return null;
    }
}
